// 用于包装vx原生message组件，使之能自动阻止频繁弹出提示
import { Message } from '@csii/vx-web';
import { throttle } from '@csii/vx-util';

// 使用节流函数包装
const ThrottleMessage = throttle(Message, 3000, { trailing: false });

['success', 'warning', 'info', 'error'].forEach((type) => {
  // 使用节流函数包装
  ThrottleMessage[type] = throttle(Message[type], 3000, { trailing: false });
});

['close', 'closeAll'].forEach((fn) => {
  ThrottleMessage[fn] = Message[fn];
});

export default ThrottleMessage;
